<!--
 * @Author: wwssaabb
 * @Date: 2021-05-26 08:19:22
 * @LastEditTime: 2021-05-26 10:28:54
 * @FilePath: \demo\canvas_demo\demo_API\drawimg.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>canvas_demo text</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    body {
      width: 100vw;
      height: 100vh;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .container{
      position: relative;
    }
    #img1{
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%,-50%);
      width: 198px;
      height: 200px;
      border-radius: 50%;
      z-index: 10;
    }
  </style>
</head>

<body>
  <div class="container">
    <canvas id="canvas1" width="800px" height="600px"></canvas>
    <img id='img1' src="../img/preview.gif" alt="">
  </div>
  

  <script type="text/javascript">
  //
    let canvas = document.querySelector('#canvas1')
    let ctx = canvas.getContext('2d')
    
    ctx.fillStyle='#fff'
    ctx.fill()
    ctx.arc(400,300,100,0,2*Math.PI)
    ctx.lineWidth=3
    ctx.stroke()

    ctx.beginPath()
    let img=new Image()
    img.src='../img/test.jpg'
    img.onload=function(){
      ctx.drawImage(img,0,0,200,200)
    }

  </script>

</body>

</html>